<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>BIBLIO: /home/marco/workspace/biblio/src/comsock.h File Reference</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />



</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">BIBLIO
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.6.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="summary">
<a href="#nested-classes">Data Structures</a> &#124;
<a href="#define-members">Defines</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">/home/marco/workspace/biblio/src/comsock.h File Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>header libreria di comunicazione socket AF_UNIX  
<a href="#details">More...</a></p>

<p><a href="comsock_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="nested-classes"></a>
Data Structures</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structmessage__t.html">message_t</a></td></tr>
<tr><td colspan="2"><h2><a name="define-members"></a>
Defines</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="comsock_8h.html#ad7871643c05865c80f5d8050aead2b57">MAXBUF</a>&#160;&#160;&#160;2048</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="comsock_8h.html#a7baab2aa5bf8eb14b6128e0f16634837">UNIX_PATH_MAX</a>&#160;&#160;&#160;108</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="comsock_8h.html#a75fe5caf5e2ff4d23a80103f78522077">MAXTRIAL</a>&#160;&#160;&#160;10</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="comsock_8h.html#acc8a34cd623ae771fbde52003c68b66e">MAXSEC</a>&#160;&#160;&#160;10</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="comsock_8h.html#ae8d18b9066459a019d8e091fa929f747">NTRIAL</a>&#160;&#160;&#160;3</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="comsock_8h.html#aa47186c9efea8899b8c1c33314071f26">NSEC</a>&#160;&#160;&#160;1</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="comsock_8h.html#abe9a795da4c8ef9d50edace5ed7aa8af">MSG_QUERY</a>&#160;&#160;&#160;'Q'</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="comsock_8h.html#a32ee7130b0d9855c703edd428790e506">MSG_LOAN</a>&#160;&#160;&#160;'L'</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="comsock_8h.html#a9afc09ab327968a17c1f5589aae420e3">MSG_RECORD</a>&#160;&#160;&#160;'R'</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="comsock_8h.html#a4ff2533d4f42b5b10b6caf648a4619b4">MSG_OK</a>&#160;&#160;&#160;'K'</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="comsock_8h.html#a3e255ce553a2f6e3c33806adf8c997aa">MSG_NO</a>&#160;&#160;&#160;'<a class="el" href="testcli_8c.html#a0240ac851181b84ac374872dc5434ee4">N</a>'</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="comsock_8h.html#aa8a990825a5a62c89d2fb8b08d8a1070">MSG_ERROR</a>&#160;&#160;&#160;'E'</td></tr>
<tr><td colspan="2"><h2><a name="func-members"></a>
Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="comsock_8h.html#ab4f598fd4b9d510f1feae85436ef9ebc">createServerChannel</a> (char *path)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="comsock_8h.html#a36c68f60410ffdbb559bb256959def46">closeServerChannel</a> (char *path, int s)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="comsock_8h.html#a870654a1e9b336f13271a7cfa0836920">acceptConnection</a> (int s)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="comsock_8h.html#a7342cc411ed1bd599f84d90d13ef4d86">receiveMessage</a> (int <a class="el" href="bibserver_8c.html#aa462bab367c8aac56ebc986ad8f4e30c">sc</a>, <a class="el" href="structmessage__t.html">message_t</a> *<a class="el" href="bibclient_8c.html#a1bac7c8cafc9909ba9c076214a6b0c0b">msg</a>)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="comsock_8h.html#aa4a2380316658b900ce7086466887c4f">sendMessage</a> (int <a class="el" href="bibserver_8c.html#aa462bab367c8aac56ebc986ad8f4e30c">sc</a>, <a class="el" href="structmessage__t.html">message_t</a> *<a class="el" href="bibclient_8c.html#a1bac7c8cafc9909ba9c076214a6b0c0b">msg</a>)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="comsock_8h.html#a88e5df18d7721b744bed4208fc97c3bb">openConnection</a> (char *path, int ntrial, int k)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="comsock_8h.html#a730d0b220efe4930f0793030846efa52">closeConnection</a> (int s)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a676cc6efe50180f0829594465607081c"></a><!-- doxytag: member="comsock.h::message_setup" ref="a676cc6efe50180f0829594465607081c" args="(message_t *msg, char *string, char type)" -->
int&#160;</td><td class="memItemRight" valign="bottom"><b>message_setup</b> (<a class="el" href="structmessage__t.html">message_t</a> *<a class="el" href="bibclient_8c.html#a1bac7c8cafc9909ba9c076214a6b0c0b">msg</a>, char *string, char type)</td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>header libreria di comunicazione socket AF_UNIX </p>
<dl class="author"><dt><b>Author:</b></dt><dd>lso12</dd></dl>
<p>Attenzione, la libreria deve funzionare senza fare assunzioni sul tipo e sulla lunghezza del messaggio inviato, inoltre deve essere possibile aggiungere tipi senza dover riprogrammare la lobreria stessa. </p>
</div><hr/><h2>Define Documentation</h2>
<a class="anchor" id="ad7871643c05865c80f5d8050aead2b57"></a><!-- doxytag: member="comsock.h::MAXBUF" ref="ad7871643c05865c80f5d8050aead2b57" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define <a class="el" href="comsock_8h.html#ad7871643c05865c80f5d8050aead2b57">MAXBUF</a>&#160;&#160;&#160;2048</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>lunghezza massima del buffer messaggio </p>

<p>Referenced by <a class="el" href="testcli_8c.html#a3c04138a5bfe5d72780bb7e82a18e627">main()</a>, <a class="el" href="bibclient_8h.html#a50fe4e9320fbfcdc05ac4fa6a9b1df95">parse_option()</a>, and <a class="el" href="comsock_8h.html#a7342cc411ed1bd599f84d90d13ef4d86">receiveMessage()</a>.</p>

</div>
</div>
<a class="anchor" id="acc8a34cd623ae771fbde52003c68b66e"></a><!-- doxytag: member="comsock.h::MAXSEC" ref="acc8a34cd623ae771fbde52003c68b66e" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define <a class="el" href="comsock_8h.html#acc8a34cd623ae771fbde52003c68b66e">MAXSEC</a>&#160;&#160;&#160;10</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>massimo numero secondi specificabili nella openConnection </p>

<p>Referenced by <a class="el" href="testcli_8c.html#a3c04138a5bfe5d72780bb7e82a18e627">main()</a>, and <a class="el" href="comsock_8h.html#a88e5df18d7721b744bed4208fc97c3bb">openConnection()</a>.</p>

</div>
</div>
<a class="anchor" id="a75fe5caf5e2ff4d23a80103f78522077"></a><!-- doxytag: member="comsock.h::MAXTRIAL" ref="a75fe5caf5e2ff4d23a80103f78522077" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define <a class="el" href="comsock_8h.html#a75fe5caf5e2ff4d23a80103f78522077">MAXTRIAL</a>&#160;&#160;&#160;10</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>massimo numero di tentativi di connessione specificabili nella openConnection </p>

<p>Referenced by <a class="el" href="testcli_8c.html#a3c04138a5bfe5d72780bb7e82a18e627">main()</a>, and <a class="el" href="comsock_8h.html#a88e5df18d7721b744bed4208fc97c3bb">openConnection()</a>.</p>

</div>
</div>
<a class="anchor" id="aa8a990825a5a62c89d2fb8b08d8a1070"></a><!-- doxytag: member="comsock.h::MSG_ERROR" ref="aa8a990825a5a62c89d2fb8b08d8a1070" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define <a class="el" href="comsock_8h.html#aa8a990825a5a62c89d2fb8b08d8a1070">MSG_ERROR</a>&#160;&#160;&#160;'E'</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>errore </p>

</div>
</div>
<a class="anchor" id="a32ee7130b0d9855c703edd428790e506"></a><!-- doxytag: member="comsock.h::MSG_LOAN" ref="a32ee7130b0d9855c703edd428790e506" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define <a class="el" href="comsock_8h.html#a32ee7130b0d9855c703edd428790e506">MSG_LOAN</a>&#160;&#160;&#160;'L'</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>richiesta di prestito di volumi con contenuti specifici </p>

<p>Referenced by <a class="el" href="bibclient_8h.html#a50fe4e9320fbfcdc05ac4fa6a9b1df95">parse_option()</a>.</p>

</div>
</div>
<a class="anchor" id="a3e255ce553a2f6e3c33806adf8c997aa"></a><!-- doxytag: member="comsock.h::MSG_NO" ref="a3e255ce553a2f6e3c33806adf8c997aa" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define <a class="el" href="comsock_8h.html#a3e255ce553a2f6e3c33806adf8c997aa">MSG_NO</a>&#160;&#160;&#160;'<a class="el" href="testcli_8c.html#a0240ac851181b84ac374872dc5434ee4">N</a>'</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>rifiuto </p>

</div>
</div>
<a class="anchor" id="a4ff2533d4f42b5b10b6caf648a4619b4"></a><!-- doxytag: member="comsock.h::MSG_OK" ref="a4ff2533d4f42b5b10b6caf648a4619b4" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define <a class="el" href="comsock_8h.html#a4ff2533d4f42b5b10b6caf648a4619b4">MSG_OK</a>&#160;&#160;&#160;'K'</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>accettazione </p>

</div>
</div>
<a class="anchor" id="abe9a795da4c8ef9d50edace5ed7aa8af"></a><!-- doxytag: member="comsock.h::MSG_QUERY" ref="abe9a795da4c8ef9d50edace5ed7aa8af" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define <a class="el" href="comsock_8h.html#abe9a795da4c8ef9d50edace5ed7aa8af">MSG_QUERY</a>&#160;&#160;&#160;'Q'</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>tipi dei messaggi scambiati fra server e client richiesta di informazioni su volumi con contenuti specifici </p>

<p>Referenced by <a class="el" href="bibclient_8c.html#a0ddf1224851353fc92bfbff6f499fa97">main()</a>.</p>

</div>
</div>
<a class="anchor" id="a9afc09ab327968a17c1f5589aae420e3"></a><!-- doxytag: member="comsock.h::MSG_RECORD" ref="a9afc09ab327968a17c1f5589aae420e3" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define <a class="el" href="comsock_8h.html#a9afc09ab327968a17c1f5589aae420e3">MSG_RECORD</a>&#160;&#160;&#160;'R'</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>richiesta di connessione utente </p>

</div>
</div>
<a class="anchor" id="aa47186c9efea8899b8c1c33314071f26"></a><!-- doxytag: member="comsock.h::NSEC" ref="aa47186c9efea8899b8c1c33314071f26" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define <a class="el" href="comsock_8h.html#aa47186c9efea8899b8c1c33314071f26">NSEC</a>&#160;&#160;&#160;1</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>numero di secondi fra due connessioni consecutive </p>

<p>Referenced by <a class="el" href="bibclient_8c.html#a0ddf1224851353fc92bfbff6f499fa97">main()</a>.</p>

</div>
</div>
<a class="anchor" id="ae8d18b9066459a019d8e091fa929f747"></a><!-- doxytag: member="comsock.h::NTRIAL" ref="ae8d18b9066459a019d8e091fa929f747" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define <a class="el" href="comsock_8h.html#ae8d18b9066459a019d8e091fa929f747">NTRIAL</a>&#160;&#160;&#160;3</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>numero di tentativi per connessione alle biblioteche </p>

<p>Referenced by <a class="el" href="bibclient_8c.html#a0ddf1224851353fc92bfbff6f499fa97">main()</a>.</p>

</div>
</div>
<a class="anchor" id="a7baab2aa5bf8eb14b6128e0f16634837"></a><!-- doxytag: member="comsock.h::UNIX_PATH_MAX" ref="a7baab2aa5bf8eb14b6128e0f16634837" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define <a class="el" href="comsock_8h.html#a7baab2aa5bf8eb14b6128e0f16634837">UNIX_PATH_MAX</a>&#160;&#160;&#160;108</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>lunghezza buffer indirizzo AF_UNIX </p>

<p>Referenced by <a class="el" href="comsock_8h.html#ab4f598fd4b9d510f1feae85436ef9ebc">createServerChannel()</a>, <a class="el" href="bibserver_8h.html#a20fc82d55de724cea43db877925aff49">init()</a>, <a class="el" href="bibclient_8c.html#a0ddf1224851353fc92bfbff6f499fa97">main()</a>, <a class="el" href="comsock_8h.html#a88e5df18d7721b744bed4208fc97c3bb">openConnection()</a>, and <a class="el" href="bibserver_8h.html#a84e414317c5f9ca3e549c1c419f2acc4">save()</a>.</p>

</div>
</div>
<hr/><h2>Function Documentation</h2>
<a class="anchor" id="a870654a1e9b336f13271a7cfa0836920"></a><!-- doxytag: member="comsock.h::acceptConnection" ref="a870654a1e9b336f13271a7cfa0836920" args="(int s)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int <a class="el" href="comsock_8h.html#a870654a1e9b336f13271a7cfa0836920">acceptConnection</a> </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>s</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>accetta una connessione da parte di un client </p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">s</td><td>socket su cui ci mettiamo in attesa di accettare la connessione</td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">c</td><td>il descrittore della socket su cui siamo connessi </td></tr>
    <tr><td class="paramname">-1</td><td>in casi di errore (setta errno) </td></tr>
  </table>
  </dd>
</dl>

<p>Referenced by <a class="el" href="testserv_8c.html#a3c04138a5bfe5d72780bb7e82a18e627">main()</a>, and <a class="el" href="bibserver_8h.html#a4d04cb98d237318ce61bc06c2689ab52">serve()</a>.</p>

</div>
</div>
<a class="anchor" id="a730d0b220efe4930f0793030846efa52"></a><!-- doxytag: member="comsock.h::closeConnection" ref="a730d0b220efe4930f0793030846efa52" args="(int s)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int <a class="el" href="comsock_8h.html#a730d0b220efe4930f0793030846efa52">closeConnection</a> </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>s</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Chiude una connessione </p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">s</td><td>file descriptor della socket relativa alla connessione</td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">0</td><td>se tutto ok, </td></tr>
    <tr><td class="paramname">-1</td><td>se errore (setta errno) </td></tr>
  </table>
  </dd>
</dl>

<p>Referenced by <a class="el" href="bibclient_8c.html#a0ddf1224851353fc92bfbff6f499fa97">main()</a>.</p>

</div>
</div>
<a class="anchor" id="a36c68f60410ffdbb559bb256959def46"></a><!-- doxytag: member="comsock.h::closeServerChannel" ref="a36c68f60410ffdbb559bb256959def46" args="(char *path, int s)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int <a class="el" href="comsock_8h.html#a36c68f60410ffdbb559bb256959def46">closeServerChannel</a> </td>
          <td>(</td>
          <td class="paramtype">char *&#160;</td>
          <td class="paramname"><em>path</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>s</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Chiude un canale lato server (rimuovendo la socket dal file system) </p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">path</td><td>path della socket </td></tr>
    <tr><td class="paramname">s</td><td>file descriptor della socket</td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">0</td><td>se tutto ok, </td></tr>
    <tr><td class="paramname">-1</td><td>se errore (setta errno) </td></tr>
  </table>
  </dd>
</dl>

<p>Referenced by <a class="el" href="bibserver_8c.html#a3c04138a5bfe5d72780bb7e82a18e627">main()</a>.</p>

</div>
</div>
<a class="anchor" id="ab4f598fd4b9d510f1feae85436ef9ebc"></a><!-- doxytag: member="comsock.h::createServerChannel" ref="ab4f598fd4b9d510f1feae85436ef9ebc" args="(char *path)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int <a class="el" href="comsock_8h.html#ab4f598fd4b9d510f1feae85436ef9ebc">createServerChannel</a> </td>
          <td>(</td>
          <td class="paramtype">char *&#160;</td>
          <td class="paramname"><em>path</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Crea una socket AF_UNIX </p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">path</td><td>pathname della socket</td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">s</td><td>il file descriptor della socket (s&gt;0) </td></tr>
    <tr><td class="paramname">-1</td><td>in altri casi di errore (setta errno) errno = E2BIG se il nome eccede UNIX_PATH_MAX</td></tr>
  </table>
  </dd>
</dl>
<p>in caso di errore ripristina la situazione inziale: rimuove eventuali socket create e chiude eventuali file descriptor rimasti aperti </p>

<p>References <a class="el" href="comsock_8h.html#a7baab2aa5bf8eb14b6128e0f16634837">UNIX_PATH_MAX</a>.</p>

<p>Referenced by <a class="el" href="bibserver_8h.html#a20fc82d55de724cea43db877925aff49">init()</a>, and <a class="el" href="testserv_8c.html#a3c04138a5bfe5d72780bb7e82a18e627">main()</a>.</p>

</div>
</div>
<a class="anchor" id="a88e5df18d7721b744bed4208fc97c3bb"></a><!-- doxytag: member="comsock.h::openConnection" ref="a88e5df18d7721b744bed4208fc97c3bb" args="(char *path, int ntrial, int k)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int <a class="el" href="comsock_8h.html#a88e5df18d7721b744bed4208fc97c3bb">openConnection</a> </td>
          <td>(</td>
          <td class="paramtype">char *&#160;</td>
          <td class="paramname"><em>path</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>ntrial</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>k</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>crea una connessione all socket del server. In caso di errore funzione ritenta ntrial volte la connessione (a distanza di k secondi l'una dall'altra) prima di ritornare errore. </p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">path</td><td>nome del socket su cui il server accetta le connessioni </td></tr>
    <tr><td class="paramname">ntrial</td><td>numeri di tentativi prima di restituire errore (ntrial &lt;=MAXTRIAL) </td></tr>
    <tr><td class="paramname">k</td><td>secondi l'uno dell'altro (k &lt;=MAXSEC)</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>fd il file descriptor della connessione se la connessione ha successo </dd></dl>
<dl class="retval"><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">-1</td><td>in caso di errore (setta errno) errno = E2BIG se il nome eccede UNIX_PATH_MAX</td></tr>
  </table>
  </dd>
</dl>
<p>in caso di errore ripristina la situazione inziale: rimuove eventuali socket create e chiude eventuali file descriptor rimasti aperti </p>

<p>References <a class="el" href="comsock_8h.html#acc8a34cd623ae771fbde52003c68b66e">MAXSEC</a>, <a class="el" href="comsock_8h.html#a75fe5caf5e2ff4d23a80103f78522077">MAXTRIAL</a>, <a class="el" href="bibserver_8c.html#aa462bab367c8aac56ebc986ad8f4e30c">sc</a>, and <a class="el" href="comsock_8h.html#a7baab2aa5bf8eb14b6128e0f16634837">UNIX_PATH_MAX</a>.</p>

<p>Referenced by <a class="el" href="bibclient_8c.html#a0ddf1224851353fc92bfbff6f499fa97">main()</a>.</p>

</div>
</div>
<a class="anchor" id="a7342cc411ed1bd599f84d90d13ef4d86"></a><!-- doxytag: member="comsock.h::receiveMessage" ref="a7342cc411ed1bd599f84d90d13ef4d86" args="(int sc, message_t *msg)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int <a class="el" href="comsock_8h.html#a7342cc411ed1bd599f84d90d13ef4d86">receiveMessage</a> </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>sc</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structmessage__t.html">message_t</a> *&#160;</td>
          <td class="paramname"><em>msg</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>legge un messaggio dalla socket --- attenzione si richiede che il messaggio sia adeguatamente spacchettato e trasferito nella struttura msg </p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">sc</td><td>file descriptor della socket </td></tr>
    <tr><td class="paramname">msg</td><td>indirizzo della struttura che conterra' il messagio letto (deve essere allocata all'esterno della funzione)</td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">lung</td><td>lunghezza del buffer letto, se OK </td></tr>
    <tr><td class="paramname">-1</td><td>in caso di errore (setta errno) errno = ENOTCONN se il peer ha chiuso la connessione (non ci sono piu' scrittori sulla socket) </td></tr>
  </table>
  </dd>
</dl>

<p>References <a class="el" href="structmessage__t.html#a670e35a55f39260aab8a626b6ba04e82">message_t::buffer</a>, <a class="el" href="structmessage__t.html#ae42a6394ce558e3e54470afd3862d9db">message_t::length</a>, <a class="el" href="comsock_8h.html#ad7871643c05865c80f5d8050aead2b57">MAXBUF</a>, and <a class="el" href="structmessage__t.html#a2088bcda29404ae1e84f99388bee473f">message_t::type</a>.</p>

<p>Referenced by <a class="el" href="bibclient_8c.html#a0ddf1224851353fc92bfbff6f499fa97">main()</a>.</p>

</div>
</div>
<a class="anchor" id="aa4a2380316658b900ce7086466887c4f"></a><!-- doxytag: member="comsock.h::sendMessage" ref="aa4a2380316658b900ce7086466887c4f" args="(int sc, message_t *msg)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int <a class="el" href="comsock_8h.html#aa4a2380316658b900ce7086466887c4f">sendMessage</a> </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>sc</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structmessage__t.html">message_t</a> *&#160;</td>
          <td class="paramname"><em>msg</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>scrive un messaggio sulla socket --- attenzione devono essere inviati SOLO i byte significativi del campo buffer (msg-&gt;length byte) -- si richiede che il messaggio venga scritto con un'unica write dopo averlo adeguatamente impacchettato </p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">sc</td><td>file descriptor della socket </td></tr>
    <tr><td class="paramname">msg</td><td>indirizzo della struttura che contiene il messaggio da scrivere</td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">n</td><td>il numero di caratteri inviati (se scrittura OK) </td></tr>
    <tr><td class="paramname">-1</td><td>in caso di errore (setta errno) errno = ENOTCONN se il peer ha chiuso la connessione (non ci sono piu' lettori sulla socket) </td></tr>
  </table>
  </dd>
</dl>

<p>References <a class="el" href="structmessage__t.html#a670e35a55f39260aab8a626b6ba04e82">message_t::buffer</a>, <a class="el" href="structmessage__t.html#ae42a6394ce558e3e54470afd3862d9db">message_t::length</a>, and <a class="el" href="structmessage__t.html#a2088bcda29404ae1e84f99388bee473f">message_t::type</a>.</p>

<p>Referenced by <a class="el" href="bibclient_8c.html#a0ddf1224851353fc92bfbff6f499fa97">main()</a>.</p>

</div>
</div>
</div><!-- contents -->


<hr class="footer"/><address class="footer"><small>
Generated on Fri Jun 29 2012 10:36:44 for BIBLIO by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.6.1
</small></address>

</body>
</html>
